const port = 7001 // dev port
const path = require('path')
const resolve = dir => path.resolve(__dirname, dir)

module.exports = {
  publicPath: './',
  //  关闭生产环境的 source map
  productionSourceMap: false,
  devServer: {
    host: '0.0.0.0',
    port,
    https: false,
    overlay: {
      warnings: false,
      errors: true
    },
    headers: {
      'Access-Control-Allow-Origin': '*'
    }
  },
  configureWebpack: config => {
    if (process.env.UNI_PROENV === 'release') {
      config.optimization.minimizer[0].options.terserOptions.compress.warnings = false
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
      config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true
      config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log']
    }
    config.resolve.alias = Object.assign(config.resolve.alias, {
      '@': resolve('src')
    })
  }
}
